<?php
session_start();
header('Content-Type:text/html;charset=utf-8');
date_default_timezone_set("PRC");
require_once($_SERVER['DOCUMENT_ROOT'].'/public/func.php');
$config=require_once($_SERVER['DOCUMENT_ROOT'].'/public/config.php');
$config2=require_once($_SERVER['DOCUMENT_ROOT'].'/public/config2.php');
isset($_SESSION['vip']['account'])?($account=$_SESSION['vip']['account']):'';
isset($account)?($arr=selects($config,'vip',"where `account`='$account'")[0]):'';
$id=$_GET['id'];
$_SESSION['id']=$id;
//var_dump($id);
$warr3=selects($config,'article',"where `id`={$id}")[0];
//var_dump($id);
$carr=selects($config,'comment',"where `aid`='$id'");
$carr0=select($config,'comment',"where `aid`='$id'");
//var_dump($carr);
$count=count($carr);
//var_dump($count);
//$count=array_count_values($aid);
//var_dump($count);
$warr0=selects($config,'article',"");
$warr1=timeselect($config2,'article',"");
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Single Post</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width">

    <!-- Bootstrap styles -->
    <link rel="stylesheet" href="/home/css/bootstrap.min.css">

    <!-- Font-Awesome -->
    <link rel="stylesheet" href="/home/css/font-awesome/css/font-awesome.min.css">

    <!-- Google Webfonts -->
    <!--<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600|PT+Serif:400,400italic' rel='stylesheet' type='text/css'>-->

    <!-- Styles -->
   <link rel="stylesheet" href="/home/css/style.css" id="theme-styles">

    <!--[if lt IE 9]>      
        <script src="js/vendor/google/html5-3.6-respond-1.1.0.min.js"></script>
    <![endif]-->

    
</head>
<body>
    <header>
        <div class="widewrapper masthead">
            <div class="container">
                <a href="index.html" id="logo">
                    <img src="/home/img/logo.png" alt="clean Blog">
                </a>

                <div id="mobile-nav-toggle" class="pull-right">
                    <a href="#" data-toggle="collapse" data-target=".clean-nav .navbar-collapse">
                        <i class="fa fa-bars"></i>
                    </a>
                </div>

                <nav class="pull-right clean-nav">
                    <div class="collapse navbar-collapse">
                        <ul class="nav nav-pills navbar-nav">
                            <li>
                                <a href="/home/landing/index.php">登陆</a>
                            </li>
                            <li>
                                <a href="/home/index.php">首页</a>
                            </li>
                            <li>
                                <a href="/home/about.php">关于我</a>
                            </li>
                            <li>
                                <a href="/home/contact.php">留言板</a>
                            </li>
                            <li>
                                <a href="/home/destroy.php">
                                退出</a>
                            </li>                         
                        </ul>
                    </div>
                </nav>        

            </div>
        </div>

        <div class="widewrapper subheader">
            <div class="container">
                <div class="clean-breadcrumb">
                    <a href="/home/landing/editor/index.php"><?php
                    echo (isset($arr['pname'])?'欢迎'.$arr['pname']:'');?>&nbsp;Blog&nbsp;博客</a>
                    <span class="separator">&#x2F;</span>
                    <a href="#">引导</a>
                    <span class="separator">&#x2F;</span>
                    <a href="#">HTML 模板</a>
                </div>

              
                <div class="clean-searchbox">
                </div>
            </div>
        </div>
    </header>

    <div class="widewrapper main">
        <div class="container">
            <div class="row">
                <div class="col-md-8 blog-main">
                    <article class="blog-post">
                        <header>
                           
                            <div class="lead-image">
                                <?php echo '<img src="'.$warr3['mfile'].'" alt="" class="img-responsive">'?>
                                
                            </div>
                        </header>
                        <div class="body">

                            <?php echo '<h1>'.$warr3['title'].'</h1>
                            <div class="meta">
                                <i class="fa fa-user"></i>'.$warr3['autor'].'<i class="fa fa-calendar"></i>'.date('Y-m-d H:i:s',$warr3['ctime']).'<i class="fa fa-comments"></i><span class="data"><a href="#comments"> '.$count.'条评论</a></span>
                            </div>
                            <p>'.$warr3['content'].'</p>'.

                            /*<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Autem quas voluptatem et minima quo amet ducimus. Voluptatum soluta tenetur ducimus fugiat, sint voluptate eveniet adipisci nulla asperiores distinctio laudantium eos. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Provident tenetur, consectetur dolores nostrum, numquam facere a dicta eum nam suscipit consequuntur dolorem aspernatur molestias vero quo id tempore vel possimus.</p>


                            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Autem quas voluptatem et minima quo amet ducimus. Voluptatum soluta tenetur ducimus fugiat, sint voluptate eveniet adipisci nulla asperiores distinctio laudantium eos. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Provident tenetur, consectetur dolores nostrum, numquam facere a dicta eum nam suscipit consequuntur dolorem aspernatur molestias vero quo id tempore vel possimus.</p>

                             <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Autem quas voluptatem et minima quo amet ducimus. Voluptatum soluta tenetur ducimus fugiat, sint voluptate eveniet adipisci nulla asperiores.</p>*/

                        '</div>
                    </article>';
                        ?>

                    <aside class="social-icons clearfix">
                        <h3>分享</h3> 
                        <a href="#"><i class="fa fa-facebook"></i></a> <a href="#"><i class="fa fa-twitter"></i></a> <a href="#"><i class="fa fa-google"></i></a>
                    </aside>

                    <aside class="comments" id="comments">
                        <hr>

                        <h2><i class="fa fa-comments"></i><?php echo $count.'条评论'?></h2>
                        <?php
                        foreach ($carr0 as $k => $v) {
                        echo
                    ' <article class="comment">
                            <header class="clearfix">
                                <img src="'.$v['mfile'].'" alt="A Smart Guy" class="avatar">
                                <div class="meta">
                                    <h3><a href="#">'.$v['uname'].'</a></h3>
                                    <span class="date">
                                        '.date('Y-m-d',$v['ctime']).'
                                    </span>
                                    <span class="separator">
                                        -
                                    </span>
                                    
                                    <a href="#create-comment" class="reply-link">回复</a>                
                                </div>
                            </header>
                             <div class="body">
                              '.$v['comment'].'
                            </div>
                        </article>';
                        }
                        ?>

                        <!--<article class="comment reply">
                            <header class="clearfix">
                                <img src="img/avatar.png" alt="A Smart Guy" class="avatar">
                                <div class="meta">
                                    <h3><a href="#">John Doe</a></h3>
                                    <span class="date">
                                        24 August 2015
                                    </span>
                                    <span class="separator">
                                        -
                                    </span>
                                    
                                    <a href="#create-comment" class="reply-link">Reply</a>                
                                </div>
                            </header>
                             <div class="body">
                               Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facere sit perspiciatis debitis, vel ducimus praesentium expedita, assumenda ipsum cum corrupti dolorum modi. Rem ipsam similique sapiente obcaecati tenetur beatae voluptatibus.
                            </div>
                        </article>

                        <article class="comment ">
                            <header class="clearfix">
                                <img src="img/avatar.png" alt="A Smart Guy" class="avatar">
                                <div class="meta">
                                    <h3><a href="#">John Doe</a></h3>
                                    <span class="date">
                                        24 August 2015
                                    </span>
                                    <span class="separator">
                                        -
                                    </span>
                                    
                                    <a href="#create-comment" class="reply-link">Reply</a>                
                                </div>
                            </header>
                             <div class="body">
                               Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facere sit perspiciatis debitis, vel ducimus praesentium expedita, assumenda ipsum cum corrupti dolorum modi. Rem ipsam similique sapiente obcaecati tenetur beatae voluptatibus.
                            </div>
                        </article>
                        <article class="comment">
                            <header class="clearfix">
                                <img src="img/avatar.png" alt="A Smart Guy" class="avatar">
                                <div class="meta">
                                    <h3><a href="#">John Doe</a></h3>
                                    <span class="date">
                                        24 August 2015
                                    </span>
                                    <span class="separator">
                                        -
                                    </span>
                                    
                                    <a href="#create-comment" class="reply-link">Reply</a>                
                                </div>
                            </header>
                             <div class="body">
                               Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facere sit perspiciatis debitis, vel ducimus praesentium expedita, assumenda ipsum cum corrupti dolorum modi. Rem ipsam similique sapiente obcaecati tenetur beatae voluptatibus.
                            </div>
                        </article>-->        
                    </aside>

                    <aside class="create-comment" id="create-comment">
                        <hr> 
                        <center>    
                        第<?php echo $_SESSION['p'] ?>页&nbsp;
                        <a href="/home/more/3.php?p=<?php echo $_SESSION['first']?>&id=<?php echo $_SESSION['id']?>">首页</a>&nbsp;
                        <a href="/home/more/3.php?p=<?php echo $_SESSION['prev']?>&id=<?php echo $_SESSION['id']?>">上一页</a>&nbsp;
                        <a href="/home/more/3.php?p=<?php echo $_SESSION['next']?>&id=<?php echo $_SESSION['id']?>">下一页</a>&nbsp;
                        <a href="/home/more/3.php?p=<?php echo $_SESSION['countpage']?>&id=<?php echo $_SESSION['id']?>">尾页</a>&nbsp;
                        共<?php echo $_SESSION['countpage']?>页
                        </center>
                        <h2><i class="fa fa-pencil"></i>添加评论</h2>

                        <form action="/home/comment/add.php" method="post" accept-charset="utf-8">
                            <div class="row">
                            <div class="col-md-6">
                            <input  type="hidden" name="id"  value="" id="comment-name" class="form-control input-lg">
                            </div>
                            <div class="col-md-6">
                            <input  type="hidden" name="aid"  value="<?php echo $id?>"id="comment-name" class="form-control input-lg">
                            </div>
                            <input  type="hidden" name="cid" id="comment-name" class="form-control input-lg">
                                <div class="col-md-6">
                                    <input type="hidden" name="uname" value="<?php echo $arr['pname']?>"id="comment-name" placeholder="姓名" class="form-control input-lg">    
                                </div>
                                <div class="col-md-6">
                                    <input type="hidden" name="ctime" id="comment-name" placeholder="时间" value="<?php echo time()?>" class="form-control input-lg">    
                                </div>
                                <div class="col-md-6">
                                    <input type="hidden" name="mfile" id="comment-name" placeholder="头像" value="<?php echo $arr['mfile']?>" class="form-control input-lg">    
                                </div>
                            </div>
                            <textarea rows="10" maxlength="100" name="comment" id="comment-body" placeholder="评论内容" class="form-control input-lg"></textarea>

                            <div class="buttons clearfix">
                                <button type="submit" class="btn btn-xlarge btn-clean-one">提交</button>
                            </div>
                        </form>
                    </aside>
                </div>
                <aside class="col-md-4 blog-aside">
                    
                    <div class="aside-widget">
                        <header>
                            <h3>精品文章</h3>
                        </header>
                        <div class="body">
                            <ul class="clean-list">
                              <?php
                            foreach ($warr0 as $k => $v) {
                          echo '<li><a href="/home/more/3.php?id='.$v['id'].'">'.$v['title'].'</a></li>';
                                /*<li><a href="">Clean - Responsive HTML5 Template</a></li>
                                <li><a href="">Responsive Pricing Table</a></li>
                                <li><a href="">Yellow HTML5 Template</a></li>
                                <li><a href="">Blackor Responsive Theme</a></li>
                                <li><a href="">Portfolio Bootstrap Template</a></li>
                                <li><a href="">Clean Slider Template</a></li>*/
                                }?>
                            </ul>
                        </div>
                    </div>
                
                    <div class="aside-widget">
                        <header>
                            <h3>相关帖子</h3>
                        </header>
                        <div class="body">
                            <ul class="clean-list">
                              <?php
                            foreach ($warr0 as $k => $v) {
                          echo '<li><a href="/home/more/3.php?id='.$v['id'].'">'.$v['title'].'</a></li>';
                                /*<li><a href="">Blackor Responsive Theme</a></li>
                                <li><a href="">Portfolio Bootstrap Template</a></li>
                                <li><a href="">Clean Slider Template</a></li>
                                <li><a href="">Clean - Responsive HTML5 Template</a></li>
                                <li><a href="">Responsive Pricing Table</a></li>
                                <li><a href="">Yellow HTML5 Template</a></li>*/
                                }?>
                            </ul>
                        </div>
                    </div>

                    <div class="aside-widget">
                        <header>
                            <h3>标签</h3>
                        </header>
                        <div class="body clearfix">
                            <ul class="tags">
                              <?php
                            foreach ($warr0 as $k => $v) {
                          echo '<li><a href="/home/more/3.php?id='.$v['id'].'">'.$v['tags'].'</a></li>';
                                /*<li><a href="#">HTML5</a></li>
                                <li><a href="#">CSS3</a></li>
                                <li><a href="#">COMPONENTS</a></li>
                                <li><a href="#">TEMPLATE</a></li>
                                <li><a href="#">PLUGIN</a></li>
                                <li><a href="#">BOOTSTRAP</a></li>
                                <li><a href="#">TUTORIAL</a></li>
                                <li><a href="#">UI/UX</a></li> */
                                }?>                           
                            </ul>
                        </div>
                    </div>
                </aside>
            </div>
        </div>
    </div>

    <footer>
        <div class="widewrapper footer">
            <div class="container">
                <div class="row">
                    <div class="col-md-4 footer-widget">
                        <h3> <i class="fa fa-user"></i>关于我</h3>

                       <p>一个程序员</p>
                       <p>刚开始接触php，学习完善技术是我现在的目标</p>
                    </div>

                    <div class="col-md-4 footer-widget">
                        <h3> <i class="fa fa-pencil"></i>最近的帖子</h3>
                        <ul class="clean-list">
                        <?php  
                        foreach ($warr1 as $key => $value) {
                       echo '<li><a href="/home/more/3.php?id='.$v['id'].'">'.$value['title'].'</a></li>';
                            /*<li><a href="">Clean - Responsive HTML5 Template</a></li>
                            <li><a href="">Responsive Pricing Table</a></li>
                            <li><a href="">Yellow HTML5 Template</a></li>
                            <li><a href="">Blackor Responsive Theme</a></li>
                            <li><a href="">Portfolio Bootstrap Template</a></li>
                            <li><a href="">Clean Slider Template</a></li>*/
                            }?>
                        </ul>
                    </div>

                    <div class="col-md-4 footer-widget">
                        <h3> <i class="fa fa-envelope"></i>联系我</h3>

                        <p>邮箱:1440342422@qq.com</p>
                        <p>电话 17671786038</p>
                         <div class="footer-widget-icon">
                            <i class="fa fa-facebook"></i><i class="fa fa-twitter"></i><i class="fa fa-google"></i>
                        </div>
                    </div>
                   
                </div>
            </div>
        </div>
        <div class="widewrapper copyright">
                Copyright 2015
        </div>
    </footer>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/modernizr.js"></script>

</body>
</html>